import 'package:flutter/material.dart';
import 'package:kepu/page/category_page/category_page.dart';
import 'package:kepu/page/game_page/game_page.dart';
import 'package:salomon_bottom_bar/salomon_bottom_bar.dart';

import '../home_page/home_page.dart';

class RootPage extends StatefulWidget {
  const RootPage({super.key});

  @override
  State<RootPage> createState() => _RootPageState();
}

class _RootPageState extends State<RootPage> {
  int _index = 0;
  List<Widget> page = [HomePage(),CategoryPage(),GamePage()];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      bottomNavigationBar: SalomonBottomBar(
        margin: EdgeInsets.symmetric(horizontal: 20),
        currentIndex: _index,
        onTap: (selectIndex) {
          setState(() {
            _index = selectIndex;
          });
        },
        items: [
          SalomonBottomBarItem(icon: Icon(Icons.home), title: Text("首页")),
          SalomonBottomBarItem(icon: Icon(Icons.category), title: Text("分类")),
          SalomonBottomBarItem(icon: Icon(Icons.query_stats), title: Text("猜一猜")),
        ],
      ),
      body: page[_index],
    );
  }
}
